package main

import (
	"fmt"
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/theme"
	"fyne.io/fyne/v2/widget"
)

func main() {
	//	创建一个APP
	a := app.New()
	// 给APP创建个一个窗口，NewWindow 函数需要传入一个窗口的命名
	w := a.NewWindow("Achou")

	grid := widget.NewList(
		func() int { return 3 },
		func() fyne.CanvasObject {
			icon := widget.NewIcon(theme.FileIcon())
			label := widget.NewLabel("List item x")
			return container.NewHBox(icon, label)
		},
		func(index widget.ListItemID, template fyne.CanvasObject) {
			cont := template.(*fyne.Container)
			label := cont.Objects[1].(*widget.Label)
			label.SetText(fmt.Sprintf("List item %v", index))
		})

	w.SetContent(grid)
	//w.Resize(fyne.NewSize(240, 360))
	// 将窗口显示处理
	w.ShowAndRun()
}
